# 导包
import unittest
from api.employee import employee_API
# 创建测试类
from utils import public


class employee_test(unittest.TestCase):
    # employee_id = None
    employee_id = None
    def setUp(self):
        self.employee = employee_API()

    # 创建测试方法
    def test_emp(self):
        add_emp_data = {"username": "dpe23237",
                "mobile": "13212092928",
                "timeOfEntry": "2022-01-16",
                "formOfEmployment": 1,
                "workNumber": "346639345",
                "departmentName": "销售",
                "departmentId": "1266699057968011025",
                "correctionTime": "2022-03-30T16:00:00.000Z"}


        response = self.employee.add_emp(add_emp_data)
        print(response.json())
        # self.assertEqual(200,response.status_code)
        # self.assertEqual(True, response.json().get("success"))
        # self.assertEqual(10000, response.json().get("code"))
        # self.assertIn("操作成功", response.json().get("message"))
        public(self, response, xycode=200, success=True, code=10000, message="操作成功")
        employee_test.employee_id = response.json().get("data").get("id")
        print(employee_test.employee_id+"创建")

    def test_update_emp(self):
        updata_emp_data = {"username": "rose0977"}
        print(self.employee_id)
        response = self.employee.updata_emp(self.employee_id,updata_emp_data)
        public(self, response, xycode=200, success=True, code=10000, message="操作成功")
        print("修改")

    def test_get_emp(self):
        response = self.employee.get_emp(self.employee_id)
        public(self, response, xycode=200, success=True, code=10000, message="操作成功")
        print("查看")

    def test_shanchu_emp(self):
        response = self.employee.de_emp(self.employee_id)
        public(self, response, xycode=200, success=True, code=10000, message="操作成功")
        print("shi")





